gusucode.com > VC++ 汽配销售管理系统(Access)源码程序 > VC++ 汽配销售管理系统(Access)源码程序/源码/BaseListBox.cpp

    //Download by http://www.NewXing.com
// BaseListBox.cpp : implementation file
//

#include "stdafx.h"
#include "qpglxt.h"
#include "BaseListBox.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBaseListBox

CBaseListBox::CBaseListBox()
{
}

CBaseListBox::~CBaseListBox()
{
}


BEGIN_MESSAGE_MAP(CBaseListBox, CListBox)
	//{{AFX_MSG_MAP(CBaseListBox)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBaseListBox message handlers

void CBaseListBox::SetDatabase(RxRecordset bsrt,CString sField)
{
	rst=bsrt;
	CString sText;
	for(int i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		sText=rst.GetFieldValue(sField);
		this->AddString(sText);
	}

}

void CBaseListBox::Refresh(CString sField)
{
	int err=0,i=0;
	while(err!=CB_ERR)
	{
		err=this->DeleteString(0);
		i++;
	}
	CString sText;
	for(i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		sText=rst.GetFieldValue(sField);
		this->AddString(sText);
	}

}

BOOL CBaseListBox::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->message==WM_KEYDOWN && pMsg->wParam==13)
		pMsg->wParam=9;
	return CListBox::PreTranslateMessage(pMsg);
}